#!coding=utf-8
import time
from concurrent.futures import ThreadPoolExecutor


def action(second):
    time.sleep(second)
    return second


lists=[4,5,2,3]

# 创建一个最大容纳数量为2的线程池
pool= ThreadPoolExecutor(max_workers=2)

# 通过submit提交执行的函数到线程池中
all_task=[pool.submit(action, i) for i in lists]

print("submit -- complete")
# 通过result来获取返回值
result=[i.result() for i in all_task]
print(f"result:{result}")


print("----complete-----")
# 线程池关闭
pool.shutdown()

